class: title-slide # ER014 - Data Science and Strategy for Business ## PVA1 ### Kurze Einführung in R und RStudio <br> <br> <br> <br> <br> <br> <br> ### FS 2024 <br> ### Prof. Dr. Jörg Schoder .mycontacts[
@FFHS-EconomicResearch
@jfschoder ] --- layout: true <div class="my-footer"></div> <div style="position: absolute;left:400px;bottom:10px;font-size:9px">
Prof. Dr. Jörg Schoder</div> --- name: agenda class: left .blockquote[Agenda] ## Datenprodukte - Theorie und Praxis * Motivation und Einordnung *
Basics * RMarkdown/Quarto * R-Projekte --- class: left .blockquote[Motivation und Einordnung] ## Daten: vom Kostenfaktor zum Asset .panelset[ .panel[.panel-name[Perspektiven] <img src="data:image/png;base64,#../../img/PVA3/data_in_business_(tableau)_1.PNG" width="100%" style="display: block; margin: auto;" /> ] .panel[.panel-name[Bewertung] <img src="data:image/png;base64,#../../img/PVA3/data_in_business_(tableau)_2.PNG" width="80%" style="display: block; margin: auto;" /> ] ] .quelle[Quelle: [cloudflight.io](https://www.cloudflight.io/de/download/uncategorized-download/turn-data-into-products-vom-data-scientist-zum-data-business-owner/)] ??? * Data is Oil * Quatsch, weil Daten mehr werden, Öl aber verbraucht wird. * Aber: Wie beim Öl entsteht der Wert auch bei Daten erst durch die Weiterverarbeitung ("Raffinerie") --- class: left .blockquote[
Basics] ##
-chitektur .right-column[ .blockquote[ "[..] the ability to run fast, frugal, and scalable experiments based on high-value business hypotheses is becoming a new core competence for innovation success. As companies gather more data about their customers, channels, usage, complaints, social media, etc., we won’t just see people analyzing data with optimization in mind; we’ll be seeing machines generating “innovation hypotheses” recommending new configurations, bundles, features, pricing schemes, and business models to test." .tr[ <a name=cite-schrage_let_2014></a>[Schrage (2014)](#bib-schrage_let_2014) ] ] ] .left-column[ <br> <img src="data:image/png;base64,#../../img/PVA3/schrage_(amazon).jpg" width="100%" /> ] .quelle[Bildquelle: [amazon.de](www.amazon.de).] ??? * Insights from Data * descriptive * predictive * prescriptive/actionable * Results vs. Methods * Data-Driven vs. Data-Informed * Data Mining vs. Data Products --- class: left .blockquote[Motivation und Einordnung] ## Warum Programmierung? .panelset[ .panel[.panel-name[Kompetenz] .fig.upper-right[ <img src="data:image/png;base64,#../../img/PVA1/Programming_Thinking_(SteveJobs).PNG" width="50%" /> ] .fig.lower-left[ <img src="data:image/png;base64,#../../img/PVA1/Programming_Quote_(Hawking).PNG" width="50%" /> ] .quellePanURL2[Bildquellen: [ilovecoding.org](https://twitter.com/ilovecodingorg/status/844202136980389888), [imrananees.blogspot.com](https://imrananees.blogspot.com/2019/10/basic-computer-programming-essential.html).] ] .panel[.panel-name[Benchmark] Beispiel: Harvard Business School * **Wahlmodule „Data Science for Managers“ (DSM)** .small[ * DSM1: „Although few HBS MBA students will be actively engaged in coding post-graduation, the course faculty believe that having **some exposure to basic, hands-on coding and techniques** will allow our students to **more effectively manage and interact with data scientists**. DSM1 will not delve deeply into technical details, but will require students to engage with some code.“ (Hervorhebung nicht im Original) * DSM2: „[..] allows students to build a deeper understanding of **how data and analytics can complement judgment for managerial decision making**. The course builds on concepts learned in DSM1 and is specifically suited for students who want to continue their career at companies such as technology companies, where data collection, aggregation, and analysis permeates the entire organization.“ (Hervorhebung nicht im Original) ] ] ] --- class: left .blockquote[Motivation und Einordnung] ## Warum R? <img src="data:image/png;base64,#../../img/PVA1/whyR.svg" width="100%" style="display: block; margin: auto;" /> .quelle[Eigene Darstellung.] ??? * März 2024: Platz 6 im [PYPL Popularity Ranking](https://pypl.github.io/PYPL.html) * Programmiersprachen. Am beliebtesten Python. Aber für statistische Anwendungen hat R, gerade im akademischen Bereich noch die Nase vorn. * Am Ende auch egal. Es konvergiert, bspw. in RMarkdown/Quarto kann nicht nur R-Code sondern auch Python und die aufstrebende Sprache Julia eingebettet werden. * somit sollte R als Einstieg gesehen werden. Je nach Anwendungsgebiet können die Sprachen dann auch kombiniert werden. --- class: inverse, center, middle ##
Basics --- class: left .blockquote[
Basics] ##
-chitektur .pull-left[ <img src="data:image/png;base64,#../../img/PVA1/R-chitektur_(Field_2012_S63).PNG" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ * Base
* der "Motor" bzw. das "Betriebssystem" * lokale Installation via CRAN (Comprehensive R Archive Network) oder diverse Mirrors * Bibliotheken (auch als Pakete bezeichnet) * die "Apps" * Erweiterung der Funktionalität ] .quelle[Bildquelle: <a name=cite-field_discovering_2012></a>[Field, Miles, and Field (2012)](#bib-field_discovering_2012), S. 63.] --- class: left .blockquote[
Basics] ##
als objektorientierte Programmiersprache * Alles ist ein Objekt * Daten (Vektoren, Matrizen, etc.) * Funktionen * Diagramme (bspw. ggplot) * Objekte können unterschiedlichen Objekt-Klassen zugeordnet werden * bspw. `character`, `numeric`, `factor`, `tibble`, etc. * Zu welcher Klasse ein Objekt gehört kann mit dem Befehl `class()` abgefragt werden. * Objekte haben eine Länge * bspw. Zahl der Elemente in einem Vektor * Die Objektlänge kann mit dem Befehl length() abgefragt werden. * Jedes Objekt wird intern durch einen Vektor repräsentiert.
ist eine Vektor-basierte Programmiersprache --- class: left .blockquote[
Basics] ## Einstieg in
* **swirl**-Paket als interaktives
-Tutorial. `install.packages(’Paketname’,dep=TRUE)` `library(Paketname)` --- class: left .blockquote[
Basics] ## Base-
vs. tidy-Syntax * Sprache vs. Dialekt --- class: inverse, center, middle ## RStudio und RMarkdown/Quarto --- class: left .blockquote[RStudio und RMarkdown/Quarto] ## RStudio als "Benutzeroberfläche" .panelset[ .panel[.panel-name[R vs. RStudio] .small[ * Die Benutzeroberfläche von
ist auf das notwendigste beschränkt: * beim Öffnen erscheint nur die sog. **
-Console**. Dort können Befehle eingegeben werden, deren Ergebnis dann unmittelbar angezeigt wird. * Statt der Eingabe in der
-Console können Eingaben auch
-Skript-Dateien (.R) erfolgen. In Base-
ist nur ein sehr rudimentärer "Texteditor" zur Bearbeitung von .R-Dateien integriert. * RStudio ist eine sog. integrierte Entwicklungsumgebung (IDE)... * ...die als kostenlose Desktop-Version verfügbar ist. * ...als Cloud-Version ([posit Cloud](https://posit.cloud/)) mit gewissen Einschränkungen ebenfalls kostenfrei verfügbar ist. * ...und ermöglicht eine anwendungsfreundliche(re) Nutzung von
(z.B. durch GUI, Kontextmenü, autocompletion etc.) * Datenprojekte können komplett in RStudio bearbeitet werden (
läuft nur im Hintergrund, muss aber nicht extra geöffnet werden). ] ] .panel[.panel-name[Quick Tour] .small[ * RStudio hat mehrere Fenster mit zusätzlichen Reitern: Skript (zur Dokumentation), Konsole (zur direkten Befehleingabe), Environment (Daten), Pakete, Plots etc. ] <p align="center"><iframe width="650" height="350" src="https://www.youtube.com/embed/SdMPh5uphO0?si=0RqBc7jmHesShdsF" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p> ] ] --- class: left .blockquote[RStudio und RMarkdown/Quarto] ## Warum RMarkdown/Quarto? .panelset[ .panel[.panel-name[Zweck] * Möglichkeit zur Integration von
-Programmcode (statistische Analysen) und Text (verbale Beschreibungen/Erläuterungen) in einer Datei * Reproduzierbarkeit von Forschung/Analysen durch Dokumentation * Leichterer Austausch von Analyseergebnissen (inkl. Dokumentation) * Zahlreiche gängige Ausgabeformate (.docx, .pptx, .pdf, .html) * Produktivitätssteigerung bei wiederkehrenden Berichten/Updates (Automatisierung) ] .panel[.panel-name[Rmd vs. qmd] * RMarkdown * Quarto ] .panel[.panel-name[Praxisbeispiel Airbnb] .blockquote[ "At Airbnb, all R analyses are documented in rmarkdown, where code and visualizations are combined within a single written report. Posts are carefully reviewed by experts in the content area and techniques used, both in terms of methodologies and code style, before publishing and sharing with the business partners." .tr[ <a name=cite-bion_how_2017></a>[Bion, Chang, and Goodman (2017)](https://doi.org/10.7287/peerj.preprints.3182v1), S. 7. ] ] <img src="data:image/png;base64,#../../img/PVA1/Rbnb.PNG" width="50%" style="display: block; margin: auto;" /> ] ] --- class: inverse, center, middle ## R-Projekte --- class: inverse, center, middle ## Key Take-Aways --- class: left .blockquote[Key Take-Aways] ## Zentrale Aspekte der Diskussion * Daten sind nur Assets, wenn sie entsprechend aufbereitet und zum Produkt entwickelt werden. * Datenprodukte vs. Daten als Produkt * Datenprodukte im Kontext von Data Mesh * Bedeutung der Datenarchitektur für Agilität * Generelle Bedeutung der Datenqualität (GiGo) --- name: EndHanks class: center background-size: 75% background-image: url(data:image/png;base64,#https://media.giphy.com/media/KJ1f5iTl4Oo7u/giphy.gif) --- class: left ## Quellenverzeichnis .ref-slide[ <a name=bib-bion_how_2017></a>[Bion, R., R. Chang, and J. Goodman](#cite-bion_how_2017) (2017). _How R Helps Airbnb Make the Most of Its Data_. Preprint. PeerJ Preprints. DOI: [10.7287/peerj.preprints.3182v1](https://doi.org/10.7287%2Fpeerj.preprints.3182v1). (Visited on Mrz. 01, 2024). <a name=bib-field_discovering_2012></a>[Field, A., J. Miles, and Z. Field](#cite-field_discovering_2012) (2012). _Discovering Statistics Using R_. Los Angeles London New Delhi Singapore Washington, DC: Sage. ISBN: 978-1-4462-8913-6 978-1-4462-0045-2 978-1-4462-0046-9. <a name=bib-schrage_let_2014></a>[Schrage, M.](#cite-schrage_let_2014) (2014). "Let Data Ask Questions, Not Just Answer Them". In: _Harvard Business Review_. ISSN: 0017-8012. (Visited on Jan. 10, 2024). ]